package com.dz.service.impl;

import com.dz.bean.Transaction;
import com.dz.bean.Work;
import com.dz.bean.dto.TransactionGuideRankDTO;
import com.dz.bean.dto.TransactionTrendDTO;
import com.dz.bean.dto.TransactionVisitorDistributionDTO;
import com.dz.mapper.TransactionDao;
import com.dz.service.TransactionService;
import com.dz.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransactionServiceImpl implements TransactionService {

    @Autowired
    private TransactionDao transactionDao;

    @Override
    public Transaction add(Transaction transaction) {
        transactionDao.add(transaction);
        Transaction result = transactionDao.findById(transaction.getId());
        return result;
    }

    @Override
    public int delete(Integer id) {
        return transactionDao.delete(id);
    }

/*    @Override
    public Transaction edit(Transaction transaction) {
        transactionDao.edit(transaction);
        Transaction result = transactionDao.findById(transaction.getId());
        return result;
    }*/

    @Override
    public Transaction findById(Integer id) {
        return transactionDao.findById(id);
    }

    @Override
    public List<Transaction> all(Transaction transaction) {
        return transactionDao.all(transaction);
    }

    @Override
    public void page(Page page, Transaction transaction) {
        int totalCount = transactionDao.pageCount(transaction);
        Object data = transactionDao.page(page,transaction);
        page.setTotalCount(totalCount);
        page.setData(data);
    }

    @Override
    public List<Work> find(Integer guideId) {
        return transactionDao.find(guideId);
    }

    @Override
    public List<TransactionTrendDTO> getTransactionTrendData(Integer days) {
        return transactionDao.getTransactionTrendData(days);
    }

    @Override
    public List<TransactionGuideRankDTO> getGuideRankData() {
        return transactionDao.getGuideRankData();
    }

    @Override
    public List<TransactionVisitorDistributionDTO> getVisitorDistributionData() {
        return transactionDao.getVisitorDistributionData();
    }
}
